@echo off

REM 参数：%1 - 操作（start|stop）
REM 示例：start-stop.bat start

IF "%1%"=="" (
    echo Usage: %0 <operation>
    echo Supported operations: start|stop
    exit /b 1
)

REM 判断是否在环境变量中找到了指定的路径
IF NOT DEFINED WORKING_DIR (
    SET "WORKING_DIR=%cd%"
) ELSE (
    REM 如果找到了，检查路径是否存在，不存在则使用当前目录
    IF NOT EXIST "%WORKING_DIR%" (
        SET "WORKING_DIR=%cd%"
    )
)

IF "%1%"=="start" (
    docker run -d --name triton_server -p 8000:8000 -v %WORKING_DIR%\model_repository:/models nvcr.io/nvidia/tritonserver:23.09-py3 tritonserver --model-repository=/models
) ELSE IF "%1%"=="stop" (
    docker stop triton_server && docker rm triton_server
) ELSE (
    echo Invalid operation. Supported operations: start|stop
)
